package makovo.utils;

import java.io.IOException;
import java.util.Properties;

import org.apache.commons.io.IOUtils;

public abstract class AsyncMail implements Runnable, Mail {
	private Properties mProperties;

	@Override
	public void run() {
		sendMail();
	}

	public abstract void sendMail();

	public AsyncMail() throws IOException {
		mProperties = new Properties();

		String[] par;

		String propFile = IOUtils.toString(this.getClass().getResourceAsStream("/makovo/resources/mail.properties"));
		String props[] = propFile.split("\n");

		for (String p : props) {
			par = p.replaceFirst("\n", "").split("=");
			mProperties.put(par[0], par[1]);
		}

	}

	@Override
	public Properties getProperties() {
		return mProperties;
	}

}
